<?php
$masterView = MasterView::getInstance();
?>
<ul>
    <?php
    foreach ($masterView->folderView->folders as $folder) :
        $streams = StreamController::getStream($folder->folderId);
        ?>
        <li class="folder-tab list-separator"><span class="context-type"></span> <span class="separator-line"></span></li>
        <li class="mozaic-widget folder-tab first mozaic-initialized widget-folder_with_streams" data-widget="folder_with_streams">
            
            <a class="expand-folder <?php echo (count($streams) + count($folder->child) > 0 ? "" : "folder-fade"); ?>"><strong></strong> <i class="icon-folder"></i> <span><?php echo $folder->folderName; ?></span></a>
            <ul class="full-menu mozaic-widget widget-list" data-guid="widget-559" data-initialized="true" data-widget="list">
                <?php
                    if (count($folder->child) > 0)
                    foreach ($folder->child as $childFolder) :
                        $childStreams = StreamController::getStream($childFolder->folderId);
                        ?>
                        <li class="mozaic-widget folder-tab first mozaic-initialized widget-folder_with_streams" data-guid="widget-499" >
                            <a class="expand-folder <?php echo (count($childStreams) > 0 ? "" : "folder-fade"); ?>"><strong></strong> <i class="icon-folder"></i> <span><?php echo $childFolder->folderName; ?></span></a>
                            <ul class="full-menu mozaic-widget widget-list" data-guid="widget-559" data-initialized="true" data-widget="list">
                                <?php
                                if (count($childStreams) > 0) :
                                    foreach ($childStreams as $stream):
                                        ?>
                                        <li class="mozaic-widget item-1000005765 folder-tab first widget-stream_in_folder" data-guid="widget-583" data-id="1000005765" data-initialized="true" >
                                            
                                            <a class="keyword type-keyword" data-id="<?php echo $stream->streamId; ?>" data-type="keyword" href="/#metrics/<?php echo base64_encode($stream->streamId); ?>"><strong></strong> <i class="icon-stream-type icon-stream-competitors-small"></i> <span><?php echo $stream->name; ?></span></a> 
                                        </li>
                                        <?php
                                    endforeach;
                                else:
                                    ?>
                                    <!--<li class="mozaic-widget folder-tab widget-permission_button" data-widget="permission_button" >
                                        <a class="has_permission empty-company folder-fade">
                                            <i class="icon-stream-type icon-plus"></i>
                                            <span>Add Stream</span>
                                        </a>
                                    </li>-->
                                <?php
                                endif;
                                ?>
                            </ul>
                        </li>
                    <?php endforeach;
                    if (count($streams) > 0) :
                        foreach ($streams as $stream):
                            ?>
                            <li class="mozaic-widget item-1000005765 folder-tab first widget-stream_in_folder" data-guid="widget-583" data-id="1000005765" data-initialized="true" >
                                
                                <a class="keyword type-keyword" data-id="<?php echo $stream->streamId; ?>" data-type="keyword" href="/#metrics/<?php echo base64_encode($stream->streamId); ?>"><strong></strong> <i class="icon-stream-type icon-stream-competitors-small"></i> <span><?php echo $stream->name; ?></span></a> 
                            </li>
                        <?php
                        endforeach;
                    else:
                        ?>
                        <!--<li class="mozaic-widget folder-tab widget-permission_button" data-widget="permission_button" >
                            <a class="has_permission empty-company folder-fade">
                                <i class="icon-stream-type icon-plus"></i>
                                <span>Add Stream</span>
                            </a>
                        </li>-->
                    <?php
                    endif;
                    ?>
            </ul>
        </li>
<?php endforeach; ?>
</ul>